
<!DOCTYPE html>
<html>
{[include file="_header.tpl"]}
<body>

<header class="navbar navbar-fixed-top bs-docs-nav">
    {[include file="_nav.tpl"]}
</header>

<main id="main" role="main">

    <div class="container docs-wrapper">
        <div class="row">

            <section id="content" class="col-lg-9 col-md-8 col-sm-8 col-xs-12">
                <h3>流量转让</h3>
                
                <p>{[$user.name]}[{[$user.id]}]，您好！</p>
                <form method="post" id="form1" name="form1">
				<table class="table table-bordered">
					<tr>
						<td align="right">当日可用：</td>
						<td>{[$user.r2*1024*1024|printsize]}</td>
					</tr>
					<tr>
						<td align="right">当月可用：</td>
						<td>{[$user.r1*1024*1024|printsize]}</td>
					</tr>
					<tr>
						<td class="col-lg-3 col-sm-4 col-xs-5" align="right">对方姓名：</td>
						<td class="col-lg-9 col-sm-8 col-xs-7"><input type="text" name="name" value="" size="12" placeholder="对方姓名"/></td>
					</tr>
					<tr>
						<td align="right">对方ID：</td>
						<td><input type="text" name="uid" value="" size="12" placeholder="对方ID"/></td>
					</tr>
					<tr>
						<td align="right">转让流量：</td>
						<td><input type="text" name="amount" value="" size="12" placeholder="转让流量，单位：MB"/></td>
					</tr>
					<tr>
						<td align="right">附言：</td>
						<td><input type="text" name="content" value="" size="12" placeholder="可选"/></td>
					</tr>
					<tr>
						<td></td>
						<td><input type="button" value="提 交" name="button1" id="button1" onclick="transfer();" class="btn-primary">
							<input type="reset" value="复 位" name="B2" class="btn-primary">
						</td>
					</tr>

				</table>
			</form>

            </section>

            <aside id="sidebar" class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
                {[include file="_left.tpl"]}
            </aside>

        </div>
    </div>
</main>

{[include file="_footer.tpl"]}

<script type="text/javascript">

function transfer() {
	$("#button1").attr('disabled', true); 
	$("#button1").val("正在提交..."); 
	
	setTimeout(_transfer, 500);
}

function _transfer() {
	var body = $('#form1').formSerialize();

	// var body = form.formSerialize();
	// alert(body);
	$.post('/t/wlan/?do=Data.transferPost', body, function(json) {
		// alert($.toJSON(json));
		
		var msg = '';
		if (json.status == 1) {
			alert("流量转让成功！");
			window.open('/t/wlan/?do=Data.layout', '_self');
			return;
		} else if (json.status == 2) {
			msg = "流量转让失败！转让流量只能为数字！请重新输入！";
		} else if (json.status == 3) {
			msg = "流量转让失败！对方姓名有误，请重新输入！";
		} else if (json.status == 4) {
			msg = "流量转让失败！对方帐号有误，请重新输入！";
		} else if (json.status == 5) {
			msg = "流量转让失败！转让流量不能大于当日或当月可用流量！请重新输入！";
		} else if (json.status == 6) {
			msg = "流量转让失败！对方姓名或帐号出错，请重新输入！";
		} else if (json.status == 8) {
			msg = "流量转让失败！不能转让给自己，请重新输入！";
		} else if (json.status == 9) {
			msg = "流量转让失败！数据不能为空，请重新输入！";
		}
		
		$("#button1").attr('disabled', false);
		$("#button1").val("提 交");
		alert(msg);

	}, 'json');
}

</script>

</body>
</html>
